package com.fjut.wx.controller;

import com.fjut.result.Result;
import com.fjut.service.OrderInfoService;
import com.fjut.vo.order.OrderFormVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "订单接口")
@RestController
@RequestMapping("/fjut/order/orderInfo")
public class OrderInfoApiController {

    @Autowired
    private OrderInfoService orderInfoService;

    @ApiOperation("提交订单")
    @PostMapping("submitOrder")
    public Result submitOrder(@RequestBody OrderFormVo orderFormVo){
        return Result.success(orderInfoService.submitOrder(orderFormVo));
    }

    @ApiOperation("查询订单信息")
    @GetMapping("getInfo/{id}")
    public Result getOrderInfo(@PathVariable Long id){
        return Result.success(orderInfoService.getOrderInfo(id));
    }

    @ApiOperation("更新订单状态")
    @PostMapping("updateOrderStatus/{outTradeNo}")
    public Result updateOrderStatus(@PathVariable String outTradeNo){
        return Result.success(orderInfoService.updateOrderStatus(outTradeNo));
    }
}
